package com.supersoul.myself.entity;
import com.supersoul.myself.entity.base.BaseEntity;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

@Data
@Entity
@Table(name = "tb_user")
@SQLDelete(sql = "update tb_user set is_delete = 1 where id = ?")
public class User extends BaseEntity{

    @Column(name = "user_name", length = 20)
    @NotEmpty
    @Size(max = 20, message = "userName不能超过20个字符")
    private String userName = "用户" + System.currentTimeMillis();

    @Column(name = "phone", nullable = false, length = 11)
    @NotEmpty
    @Size(max = 11, message = "phone为11位")
    @Pattern(regexp = "^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$", message = "手机号格式不对")
    private String phone;
    /**
     * 1.boy  2. girl
     */
    @Column(name = "sex", columnDefinition = "int(11) comment ' 1.boy  2. girl' ")
    private Integer sex;
    /**
     * 用户头像
     */
    @Column(name = "head_img_url", length = 1000)
    @Size(max = 1000, message = "headImgUrl不能超过1000个字符")
    private String headImgUrl = "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg";

    @Column(name = "score")
    private Long score = 0L;

    @Transient
    private String token;

}
